var lenageinf_female_3rd = [
    [0, 17.75390038],
    [0.5, 18.68865494],
    [1.5, 20.06182407],
    [2.5, 21.1138905],
    [3.5, 21.99190139],
    [4.5, 22.75776862],
    [5.5, 23.44410438],
    [6.5, 24.07045836],
    [7.5, 24.64959275],
    [8.5, 25.1903604],
    [9.5, 25.69918847],
    [10.5, 26.18091152],
    [11.5, 26.63927087],
    [12.5, 27.07722995],
    [13.5, 27.49718207],
    [14.5, 27.90109205],
    [15.5, 28.29059591],
    [16.5, 28.66707257],
    [17.5, 29.03169681],
    [18.5, 29.38547891],
    [19.5, 29.72929509],
    [20.5, 30.06391097],
    [21.5, 30.39000009],
    [22.5, 30.7081586],
    [23.5, 31.01891747],
    [24.5, 31.32275048],
    [25.5, 31.6299319],
    [26.5, 31.93439333],
    [27.5, 32.23361692],
    [28.5, 32.5256335],
    [29.5, 32.80896769],
    [30.5, 33.08258407],
    [31.5, 33.34583185],
    [32.5, 33.59839185],
    [33.5, 33.84022851],
    [34.5, 34.07154155],
    [35.5, 34.29273062]


];
var lenageinf_female_5th = [
    [0, 17.94316221],
    [0.5, 18.88317546],
    [1.5, 20.26771051],
    [2.5, 21.33035547],
    [3.5, 22.21786612],
    [4.5, 22.9922661],
    [5.5, 23.68632411],
    [6.5, 24.31972973],
    [7.5, 24.90535972],
    [8.5, 25.45215874],
    [9.5, 25.96662724],
    [10.5, 26.45365856],
    [11.5, 26.91704152],
    [12.5, 27.35977823],
    [13.5, 27.78429371],
    [14.5, 28.19257909],
    [15.5, 28.5862923],
    [16.5, 28.96683068],
    [17.5, 29.33538461],
    [18.5, 29.69297766],
    [19.5, 30.04049742],
    [20.5, 30.37871934],
    [21.5, 30.70832548],
    [22.5, 31.0299194],
    [23.5, 31.34403841],
    [24.5, 31.65116244],
    [25.5, 31.96381353],
    [26.5, 32.27254864],
    [27.5, 32.57515329],
    [28.5, 32.86990254],
    [29.5, 33.15551353],
    [30.5, 33.43109833],
    [31.5, 33.69611617],
    [32.5, 33.95032767],
    [33.5, 34.19375243],
    [34.5, 34.42662774],
    [35.5, 34.64937522]


];

var lenageinf_female_10th = [
    [0, 18.24384312],
    [0.5, 19.18996378],
    [1.5, 20.58909329],
    [2.5, 21.66593416],
    [3.5, 22.56651785],
    [4.5, 23.35289752],
    [5.5, 24.05798872],
    [6.5, 24.70162863],
    [7.5, 25.29681988],
    [8.5, 25.85260998],
    [9.5, 26.37558263],
    [10.5, 26.87069863],
    [11.5, 27.34180179],
    [12.5, 27.79193946],
    [13.5, 28.22357414],
    [14.5, 28.63872828],
    [15.5, 29.03908619],
    [16.5, 29.42606763],
    [17.5, 29.8008821],
    [18.5, 30.16456966],
    [19.5, 30.51803218],
    [20.5, 30.86205753],
    [21.5, 31.19733865],
    [22.5, 31.52448869],
    [23.5, 31.84405321],
    [24.5, 32.15652025],
    [25.5, 32.47764908],
    [26.5, 32.79316326],
    [27.5, 33.10126721],
    [28.5, 33.40057403],
    [29.5, 33.69006861],
    [30.5, 33.96906963],
    [31.5, 34.23719202],
    [32.5, 34.49431059],
    [33.5, 34.74052525],
    [34.5, 34.97612903],
    [35.5, 35.20157761]


];

var lenageinf_female_25th = [
    [0, 18.77302379],
    [0.5, 19.72318196],
    [1.5, 21.13811432],
    [2.5, 22.23278845],
    [3.5, 23.15098182],
    [4.5, 23.95428943],
    [5.5, 24.67556336],
    [6.5, 25.33468039],
    [7.5, 25.9447073],
    [8.5, 26.51475681],
    [9.5, 27.05147204],
    [10.5, 27.55986594],
    [11.5, 28.04382751],
    [12.5, 28.50644311],
    [13.5, 28.95020902],
    [14.5, 29.37717703],
    [15.5, 29.78905704],
    [16.5, 30.18729128],
    [17.5, 30.57310903],
    [18.5, 30.94756789],
    [19.5, 31.31158533],
    [20.5, 31.66596317],
    [21.5, 32.01140686],
    [22.5, 32.34854084],
    [23.5, 32.67792064],
    [24.5, 33.00004419],
    [25.5, 33.33548577],
    [26.5, 33.66285375],
    [27.5, 33.9809263],
    [28.5, 34.28878188],
    [29.5, 34.58577734],
    [30.5, 34.8715223],
    [31.5, 35.14585477],
    [32.5, 35.40881672],
    [33.5, 35.66062924],
    [34.5, 35.90167215],
    [35.5, 36.13245789]


];

var lenageinf_female_50th = [
    [0, 19.40410344],
    [0.5, 20.34787736],
    [1.5, 21.76620393],
    [2.5, 22.87159466],
    [3.5, 23.80308673],
    [4.5, 24.62075997],
    [5.5, 25.35683559],
    [6.5, 26.03088631],
    [7.5, 26.65581919],
    [8.5, 27.24065886],
    [9.5, 27.79199896],
    [10.5, 28.31482503],
    [11.5, 28.81301178],
    [12.5, 29.28963935],
    [13.5, 29.74720283],
    [14.5, 30.18775595],
    [15.5, 30.61301254],
    [16.5, 31.02441992],
    [17.5, 31.42321324],
    [18.5, 31.81045628],
    [19.5, 32.18707286],
    [20.5, 32.55387116],
    [21.5, 32.91156289],
    [22.5, 33.26077861],
    [23.5, 33.60207966],
    [24.5, 33.93596986],
    [25.5, 34.28752371],
    [26.5, 34.62881469],
    [27.5, 34.95908124],
    [28.5, 35.27777948],
    [29.5, 35.58457311],
    [30.5, 35.87931749],
    [31.5, 36.16204457],
    [32.5, 36.43294692],
    [33.5, 36.69236008],
    [34.5, 36.94074984],
    [35.5, 37.17869046]


];

var lenageinf_female_75th = [
    [0, 20.08611153],
    [0.5, 21.00931189],
    [1.5, 22.41393367],
    [2.5, 23.5198737],
    [3.5, 24.45800342],
    [4.5, 25.28547478],
    [5.5, 26.03315521],
    [6.5, 26.71989607],
    [7.5, 27.35818387],
    [8.5, 27.95678244],
    [9.5, 28.52211646],
    [10.5, 29.0590584],
    [11.5, 29.57140552],
    [12.5, 30.06218402],
    [13.5, 30.53385099],
    [14.5, 30.98843329],
    [15.5, 31.42762572],
    [16.5, 31.85286224],
    [17.5, 32.26536875],
    [18.5, 32.66620284],
    [19.5, 33.05628437],
    [20.5, 33.43641927],
    [21.5, 33.80731824],
    [22.5, 34.16961181],
    [23.5, 34.52386205],
    [24.5, 34.87057376],
    [25.5, 35.23845382],
    [26.5, 35.59443641],
    [27.5, 35.93804317],
    [28.5, 36.26896895],
    [29.5, 36.58707733],
    [30.5, 36.89239047],
    [31.5, 37.18507828],
    [32.5, 37.46544644],
    [33.5, 37.73392264],
    [34.5, 37.99104618],
    [35.5, 38.23745059]


];

var lenageinf_female_90th = [
    [0, 20.74902741],
    [0.5, 21.63868206],
    [1.5, 23.01423435],
    [2.5, 24.11145298],
    [3.5, 25.04980821],
    [4.5, 25.88228128],
    [5.5, 26.63779083],
    [6.5, 27.33414242],
    [7.5, 27.98320827],
    [8.5, 28.59336778],
    [9.5, 29.17079336],
    [10.5, 29.72018585],
    [11.5, 30.24522242],
    [12.5, 30.74884327],
    [13.5, 31.23344287],
    [14.5, 31.70100175],
    [15.5, 32.15318014],
    [16.5, 32.59138592],
    [17.5, 33.01682526],
    [18.5, 33.43054075],
    [19.5, 33.8334409],
    [20.5, 34.22632299],
    [21.5, 34.60989129],
    [22.5, 34.98477149],
    [23.5, 35.35152244],
    [24.5, 35.71064587],
    [25.5, 36.09339742],
    [26.5, 36.46324105],
    [27.5, 36.81980951],
    [28.5, 37.16289981],
    [29.5, 37.49246824],
    [30.5, 37.80862172],
    [31.5, 38.11160723],
    [32.5, 38.40179992],
    [33.5, 38.67969047],
    [34.5, 38.94587266],
    [35.5, 39.20103004]


];

var lenageinf_female_95th = [
    [0, 21.17044796],
    [0.5, 22.03187893],
    [1.5, 23.38155095],
    [2.5, 24.46916903],
    [3.5, 25.40503469],
    [4.5, 26.23880376],
    [5.5, 26.99785555],
    [6.5, 27.69917601],
    [7.5, 28.35415883],
    [8.5, 28.97088496],
    [9.5, 29.55533127],
    [10.5, 30.11206545],
    [11.5, 30.64467121],
    [12.5, 31.15602151],
    [13.5, 31.64846142],
    [14.5, 32.12393461],
    [15.5, 32.5840734],
    [16.5, 33.03026434],
    [17.5, 33.46369708],
    [18.5, 33.88540143],
    [19.5, 34.29627585],
    [20.5, 34.69710979],
    [21.5, 35.08860133],
    [22.5, 35.47137134],
    [23.5, 35.84597507],
    [24.5, 36.21291077],
    [25.5, 36.60464076],
    [26.5, 36.98306199],
    [27.5, 37.34781125],
    [28.5, 37.69869787],
    [29.5, 38.03569559],
    [30.5, 38.35893333],
    [31.5, 38.66868312],
    [32.5, 38.96534694],
    [33.5, 39.24944385],
    [34.5, 39.52159458],
    [35.5, 39.78251075]


];

var lenageinf_female_97th = [
    [0, 21.45484373],
    [0.5, 22.29421701],
    [1.5, 23.62338981],
    [2.5, 24.70295427],
    [3.5, 25.63614495],
    [4.5, 26.47008414],
    [5.5, 27.23098958],
    [6.5, 27.93523343],
    [7.5, 28.59385304],
    [8.5, 29.21470805],
    [9.5, 29.80363071],
    [10.5, 30.36509041],
    [11.5, 30.90260182],
    [12.5, 31.4189882],
    [13.5, 31.91655805],
    [14.5, 32.39722767],
    [15.5, 32.86260856],
    [16.5, 33.31407125],
    [17.5, 33.75279297],
    [18.5, 34.17979375],
    [19.5, 34.59596435],
    [20.5, 35.00208813],
    [21.5, 35.39885828],
    [22.5, 35.78689181],
    [23.5, 36.16674104],
    [24.5, 36.53890131],
    [25.5, 36.93649297],
    [26.5, 37.32059597],
    [27.5, 37.69082538],
    [28.5, 38.04697959],
    [29.5, 38.38902887],
    [30.5, 38.71710512],
    [31.5, 39.03148827],
    [32.5, 39.33259184],
    [33.5, 39.6209495],
    [34.5, 39.89719708],
    [35.5, 40.16206358]


];

$(function chartSetup() {
    $('#container').highcharts({
        chart: {
            type: 'areaspline'
        },
        title: {
            text: 'Infant Length Growth Chart (Females)'
        },
        legend: {
            layout: 'horizontal',
            align: 'center',
            verticalAlign: 'bottom',
            borderWidth: 1,
            backgroundColor: '#FFFFFF',
            itemStyle: {
                cursor: 'pointer',
                color: '#274b6d',
                fontSize: '12px'
            }
        },
        plotOptions: {
            areaspline: {
                fillOpacity: 0.2
            },
            series: {
                minPointLength: 1,
                shadow: false,
                events: {
                    legendItemClick: function () {
                        if (this.name == 'Percentiles') {
                            toggleBands(chart);
                        }
                    }
                }
            }
        },
        xAxis: {
            title: {
                text: 'Age (months)'
            },
            labels: {
                rotation: -90
            }
        },
        yAxis: {
            title: {
                text: 'Length (inches)'
            },
            min: 16
        },
        tooltip: {
            shared: true,
            valueSuffix: ' inches',
            valueDecimals: 2
        },
        credits: {
            enabled: false
        },
        series: [{
            name: '3rd Percentile',
            data: lenageinf_female_3rd,
            marker: {
                enabled: false
            }
        }, {
            name: '5th Percentile',
            data: lenageinf_female_5th,
            marker: {
                enabled: false
            }
        }, {
            name: '10th Percentile',
            data: lenageinf_female_10th,
            marker: {
                enabled: false
            }
        }, {
            name: '25th Percentile',
            data: lenageinf_female_25th,
            marker: {
                enabled: false
            }
        }, {
            name: '50th Percentile',
            data: lenageinf_female_50th,
            marker: {
                enabled: false
            }
        }, {
            name: '75th Percentile',
            data: lenageinf_female_75th,
            marker: {
                enabled: false
            }
        }, {
            name: '90th Percentile',
            data: lenageinf_female_90th,
            marker: {
                enabled: false
            }
        }, {
            name: '95th Percentile',
            data: lenageinf_female_95th,
            marker: {
                enabled: false
            }
        }, {
            name: '97th Percentile',
            data: lenageinf_female_97th,
            marker: {
                enabled: false
            }
        }]
    });
});

function toggleBands(chart) {
    $.each(chart.xAxis, function (index, elX) {
        $.each(elX.plotLinesAndBands, function (index, el) {
            if (el.svgElem !== undefined) {
                el.svgElem[el.visible ? 'show' : 'hide']();
                el.visible = !el.visible;
            }
        });
    });
}

$('.toggle-trigger').click(function () {
    var target = $(this).attr('data-target');

    $('#' + target).slideToggle('slow');

    if ($(this).hasClass('plus')) {
        $(this).addClass('minus').removeClass('plus');
    } else {
        $(this).addClass('plus').removeClass('minus');
    }
});